package com.ruoyi.web.controller.system;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysDo1;
import com.ruoyi.system.service.ISysDo1Service;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 劳动收入Controller
 * 
 * @author fengzy
 * @date 2022-04-11
 */
@RestController
@RequestMapping("/system/do1")
public class SysDo1Controller extends BaseController
{
    @Autowired
    private ISysDo1Service sysDo1Service;

    /**
     * 查询劳动收入列表
     */
    @PreAuthorize("@ss.hasPermi('system:do1:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysDo1 sysDo1)
    {
        startPage();
        List<SysDo1> list = sysDo1Service.selectSysDo1List(sysDo1);
        return getDataTable(list);
    }

    /**
     * 导出劳动收入列表
     */
    @PreAuthorize("@ss.hasPermi('system:do1:export')")
    @Log(title = "劳动收入", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SysDo1 sysDo1)
    {
        List<SysDo1> list = sysDo1Service.selectSysDo1List(sysDo1);
        ExcelUtil<SysDo1> util = new ExcelUtil<SysDo1>(SysDo1.class);
        return util.exportExcel(list, "do1");
    }

    /**
     * 获取劳动收入详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:do1:query')")
    @GetMapping(value = "/{doId}")
    public AjaxResult getInfo(@PathVariable("doId") Long doId)
    {
        return AjaxResult.success(sysDo1Service.selectSysDo1ById(doId));
    }

    /**
     * 新增劳动收入
     */
    @PreAuthorize("@ss.hasPermi('system:do1:add')")
    @Log(title = "劳动收入", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysDo1 sysDo1)
    {
        return toAjax(sysDo1Service.insertSysDo1(sysDo1));
    }

    /**
     * 修改劳动收入
     */
    @PreAuthorize("@ss.hasPermi('system:do1:edit')")
    @Log(title = "劳动收入", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysDo1 sysDo1)
    {
        return toAjax(sysDo1Service.updateSysDo1(sysDo1));
    }

    /**
     * 删除劳动收入
     */
    @PreAuthorize("@ss.hasPermi('system:do1:remove')")
    @Log(title = "劳动收入", businessType = BusinessType.DELETE)
	@DeleteMapping("/{doIds}")
    public AjaxResult remove(@PathVariable Long[] doIds)
    {
        return toAjax(sysDo1Service.deleteSysDo1ByIds(doIds));
    }
}
